package com.example.touch;

import java.lang.reflect.InvocationTargetException;

public class Area 
{
	static Logic logic;
	
	private float mX, mY;
	private float mWidth, mHeight;

	private int mId;
	private String mDescription;
	private String mCallback;
	
	public Area()
	{
		this(0,0,0,0,"");	
	}
	public Area(float x, float y, float width, float height, String desc)
	{
		mX = x;
		mY = y;
		mWidth = width;
		mHeight = height;
		mDescription = desc;
		mId = 0;
	}
	
	public boolean isInArea(float x, float y)
	{
		if((mX <= x) && (x <= mX + mWidth)){
			if((mY <= y) && (y <= mY + mHeight)){
				return true;
			}
		}
		return false;
	}
	
	public int getId()
	{
		return mId;
	}
	public void setId(int id)
	{
		mId = id;
	}
	
	public String getDescription()
	{
		return mDescription;
	}
	
	static public void setLogic(Logic l)
	{
		logic = l;
	}
	public void setCallback(String callbackName)
	{
		mCallback = callbackName;
	}
	public void execute()
	{
		try
		{
			logic.getClass().getMethod(mCallback).invoke(logic);
		}catch(NoSuchMethodException e){	
		}catch(IllegalAccessException e){	
		}catch(InvocationTargetException e){
		}
	}
	
}
